"use strict";

if (typeof(alx) == "undefined") { 
	var alx = {};
}

(function() {
	alx.lj = {
		inherit: function (target, obj, overWrite) {
			for (var key in obj) {
				if (obj.hasOwnProperty(key)) {
					if (!target[key] || overWrite) {
						target[key] = obj[key];
					}
				}
			}
		},
		
		getElementRoot: function (obj) {
			while (obj && obj.nodeType != 9) {
				obj = obj.parentNode;
			}
			
			return obj;
		},
		
		getElementPhysicalProps: function(elem) { 
			var totalOffsetTop = 0,
					totalOffsetLeft = 0,
					current = elem;
			
			while (current != null) {
				totalOffsetTop += current.offsetTop;
				totalOffsetLeft += current.offsetLeft;
				
				current = current.offsetParent;
			}
					
			return { 
					top: totalOffsetTop, 
					left: totalOffsetLeft,
					width: elem.offsetWidth,
					height: elem.offsetHeight
			};
		}
	};
})();